<? FoundryView::includeTpl( 'adminMain:header' ) ?>

<script type="text/javascript" src="<?=Foundry::config('webpath')?>/javascript/admin/newsRules.js"></script>

<div id="mainContent">

	<h2>News</h2>
	
	<a href="<?=FoundryView::helperLinkTo('newsAdmin/post')?>" class="actionLink">
		<img src="<?=Foundry::config('webpath')?>/images/admin/add.png" />
		new post</a>
	<span id="actionMessage"></span>
	<p />
		
	<?php
		$model = FoundryController::model( 'net.mode3.news:news' );
		$posts = $model->find( 'order by *modified desc' );		
	?>
		
	<ul class="assetList">
	<? foreach( $posts as $post ) : ?>
	
		<li id="postContainer<?=$post->uid?>">
			<span class="label"><a href="<?=FoundryView::helperLinkTo('newsAdmin/post')?>/<?=$post->uid?>"><?=$post->headline?></a></span>
			<span class="describe">
				<?php echo date('m/d/Y g:ia', $post->added ) ?>
				Status:
				<?php if( $post->published ) : ?>
					Published 
				<?php else: ?>
					Draft
				<?php endif ?>
			</span>
			<span class="icons">
			<img src="<?=Foundry::config('webpath')?>/images/admin/cross.png" title="Delete this post" class="newsDeletePost" for="<?=$post->uid?>" />
			<? if( $post->published == 1 ) : ?>
				<img src="<?=Foundry::config('webpath')?>/images/admin/star.png" title="Publish this post" />
			<? else: ?>
				<img src="<?=Foundry::config('webpath')?>/images/admin/star_inactive.png" title="Publish this post" class="newsPublishPost" for="<?=$post->uid?>" id="newsPublishPostStatus<?=$post->uid?>" />
			<? endif ?>

			<a href="<?=FoundryView::helperLinkTo('news/')?><?=$post->uid?>" target="new" class="iconLink"><img src="<?=Foundry::config('webpath')?>/images/admin/world.png" title="Preview this post" /></a>
			</span>
		</li>
		<li id="infoBumper<?=$post->uid?>" style="display: none"></li>
	
	<? endforeach ?>
	</ul>
	
</div>

<? FoundryView::includeTpl( 'adminMain:footer' ) ?>